<?

class user_auth {





// start the timeout timer
function start_timer(){

	//session_set_cookie_params(0);
	session_start();
	$_SESSION['timeout'] = time();
	
}

function user_auth_cp($seconds='3600', $url="/"){

	session_start();
	$current_time = time();
	$last_session_time = $_SESSION['timeout'];
	$time_diff = $current_time - $last_session_time;

	if ($time_diff > $seconds || !isset($last_session_time)){
		session_unset();
		session_destroy();
		if(isset($url)){
			header ('Location: '.$url);
			exit;
		}
	}else{
		$_SESSION['timeout'] = time();
	}


	/*ini_set('session.gc_maxlifetime', '3610');
	//ini_set('session.cookie_lifetime', '1');
	// set the cache limiter to 'private'
	//session_cache_limiter('private');
	//$cache_limiter = session_cache_limiter();
	
	// set the cache expire to 30 minutes
	//session_cache_expire(1);
	//$cache_expire = session_cache_expire();
	//var_dump($cache_expire);
	//session_start();	
	
	
    session_set_cookie_params('3600');
    session_start();

	if(!isset($_SESSION['logged_in'])){

		session_destroy();
		header("Location: /?out=true");
		exit;
		
	}*/
	

	
}



function user_auth_bookings($seconds='3600', $url="/"){

	session_start();
	$current_time = time();
	$last_session_time = $_SESSION['timeout'];
	$time_diff = $current_time - $last_session_time;

	if ($time_diff > $seconds || !isset($last_session_time)){
		session_unset();
		session_destroy();
		if(isset($url)){
			header ('Location: '.$url);
			exit;
		}
	}else{
		$_SESSION['timeout'] = time();
	}
	
	
}





}

?>